<?php
include_once "../conn.php";

$q = "select * from job_seeker_info where uname = \"$uname\"";
$r = mysql_query($q) or die(mysql_error());
$a = mysql_fetch_array($r);

$use_month = date("m", strtotime("$a[bmonth] $a[bday] $a[byear]"));

		if((date(m) > $use_month) || (date(m) == $use_month && date(d) >= $a[bday]))
		{
		    $age = date(Y) - $a[byear];		    
		}
		else
		{
			$age = date(Y) - $a[byear];
		}

$q1 = "select * from job_work_experience where uname = \"$uname\" order by WEn desc ";
$r1 = mysql_query($q1) or die(mysql_error());
while ($a1 = mysql_fetch_array($r1))
{
	$working = "
	<table align=center width=460 border=1 bordercolor=black cellspacing=0 cellpadding=0 class=BlackText>
	<caption class=HeaderClass>Work Experince $a1[WEn]</caption>

	<tr>
		<td><b>Position : </b></td><td bgcolor=dddddd colspan=2> $a1[WE_p]</td>
	</tr>

	<tr>
		<td><b>From date :</b></td><td bgcolor=dddddd colspan=2> $a1[WE_Start] </td>
	</tr>
	
	<tr>
		<td><b>To date :</b></td><td bgcolor=dddddd colspan=2> $a1[WE_End] </td>
	</tr>
	
	<tr>
	<td colspan=4>
			<table cellspacing=0 width=100% class=BlackText>
			<tr>
			
			<td valign=top bgcolor=white>
			<b>Description: </b>
			</td>
			</tr>

			<tr>
			<td bgcolor=dddddd>
			$a1[WE_d] 
			</td>
			
			</tr>
			</table>
		</td>
	</td>
	</tr>
	</table><br>
	";
}


$q1 = "select * from job_education where uname = \"$uname\" order by En asc ";
$r2 = mysql_query($q1) or die(mysql_error());

echo "<br><br>";
while ($a1 = mysql_fetch_array($r2))
{

	$education = "
	<table align=center width=460 border=1 bordercolor=black cellspacing=0 cellpadding=0 class=BlackText>
	<caption class=HeaderClass>Education $a1[En]</caption>

	<tr>
		<td><b>Education Institution : </b></td><td bgcolor=dddddd colspan=2> $a1[E_i]</td>
	</tr>

	<tr>
		<td><b>Graduate Level : </b></td><td bgcolor=dddddd colspan=2> $a1[E_gr]</td>		
	</tr>
	
	<tr>
		<td><b>From date :</b></td><td bgcolor=dddddd colspan=2> $a1[E_Start] </td>
	</tr>
	
	<tr>
		<td><b>To date :</b></td><td bgcolor=dddddd colspan=2> $a1[E_End] </td>
	</tr>
	
	<tr>
	<td colspan=4>
			<table cellspacing=0 width=100% class=BlackText>
			<tr>
			
			<td valign=top bgcolor=white>
			<b>Description: </b>
			</td>
			</tr>

			<tr>
			<td bgcolor=dddddd>
			$a1[E_d] 
			</td>
			
			</tr>
			</table>
		</td>
	</td>
	</tr>
	</table><br>
	";
}


$q4 = "select * from job_skills where uname = \"$uname\" ";
$r4 = mysql_query($q4) or die(mysql_error());

while($a4 = mysql_fetch_array($r4))
{
$aaa = stripslashes($a4[SK_d]);
$aaa = nl2br($aaa);
$bbb = stripslashes($a4[expertise]);
$bbb = nl2br($bbb);

if(!empty($bbb)){
	$expert = "
	<table align=center width=460 border=1 bordercolor=black cellspacing=0 class=BlackText>
	<caption class=HeaderClass>My Expertise</caption>

	<tr>
	<td colspan=2> $bbb </td>
	</tr>
	</table>	
		<br><br>
	";
}
else
{
	$expert = " ";
}

$additional ="

	$expert
	<table align=center width=460 border=1 bordercolor=black cellspacing=0 class=BlackText>
	<caption class=HeaderClass>My additional skills</caption>

	<tr>
	<td colspan=2> $aaa </td>
	</tr>
	</table>	
		<br><br>
		";
}


if(!empty($a[phone2]))
{
		$mobile = "<tr>
									<td valign=top><b>Mobile:</b></td>
		 							<td bgcolor=dddddd valign=top>$a[phone2]</td>
							 </tr>";
}	
else
{
		$mobile = " ";
}

if(!empty($a[fax]))
{
		$fax = "<tr>
									<td valign=top><b>Fax:</b></td>
		 							<td bgcolor=dddddd valign=top>$a[fax]</td>
							 </tr>";
}	
else
{
		$fax = " ";
}

$filepnt = fopen("$a[fname].doc", 'w+');
flock($filepnt, LOCK_EX);
$content = 
"<table width=460 align=center cellpadding=0 class=BlackText>
<caption align=center><b> $a[rTitle] <br><br><br></b> 

<img src=http://$_SERVER[HTTP_HOST]$dir/re_images/$a[image] width=150 height=200><br><br>
<table cellspacing=0 width=100% class=BlackText>			
			<tr>			
			<td valign=top>
			<b>My Introduce: </b>
			</td>
			</tr>

			<tr>
			<td bgcolor=dddddd>
			$a[rPar] 
			</td>
			
			</tr>
			</table><br><br>
</caption>
	<tr>
		<td valign=top>

			<table width=460 align=center  cellspacing=0 border=1 rules=rows bordercolor=black class=BlackText>		
				<tr>
					<td><b>Name:</b></td>
					<td bgcolor=dddddd width=400 valign=top>
					$a[title] $a[fname] $a[lname]
					</td>
				</tr>
				<tr>
					<td><b>Age: </b></td>
					<td bgcolor=dddddd valign=top>
					$age
					</td>
				</tr>
				<tr>
					<td valign=top><b>Phone:</b></td>
					<td bgcolor=dddddd valign=top>$a[phone]</td>
				</tr>
				$mobile
				$fax
			</table>
		</td>
	</tr>
</table>
<tr>
	<td valign=top>
		<table align=center width=460  cellpadding=0 cellspacing=0 border=1 bordercolor=black rules=rows class=BlackText>

			<tr>
				<td colspan=2><b> Address: </b></td>
			</tr>
			<tr>
				<td bgcolor=dddddd colspan=2>
				$a[city], $a[address] $a[street], $a[zip] $a[state]
				</td>
			</tr>
			<tr>
				<td><b> Country: </b></td>
					<td bgcolor=dddddd>$a[country]</td>
			</tr>
			<tr>
				<td><b> Nationality: </b></td>
				<td bgcolor=dddddd>$a[nationality]</td>
			</tr>
			<tr>
				<td><b>E-mail: </b></td>
				<td bgcolor=dddddd>$a[job_seeker_email]</td>
			</tr>
	</table>
</td>
</tr>
</table>
<br>
<table align=center width=460 border = 1 bordercolor=black  cellspacing=0 class=BlackText>
<tr>
	<td width=200><b>Career level </b></td>
	<td width=300 bgcolor=dddddd>$a[careerlevel]</td>
</tr>

<tr>
	<td valign=top><b>Marital status:</b></td>
	<td bgcolor=dddddd valign=top>$a[maritalstatus]</td>
</tr>

<tr>
	<td valign=top><b>Required income:</b></td>
	<td bgcolor=dddddd valign=top>$a[income]</td>
</tr>

<tr>
	<td valign=top><b>Target company:</b></td>
	<td bgcolor=dddddd valign=top>$a[target_company]</td>
</tr>

<tr>
	<td><b>Availability Employment</b></td>
	<td bgcolor=dddddd>$a[employment]</td>
</tr>
</table>
<br>
$working
<br>
$education
<br>
$additional

";
fwrite($filepnt, $content);
fflush($filepnt); 
flock($filepnt, LOCK_UN);
fclose($filepnt);
 
?>

<center><a href="<?=$a[fname]?>.doc">Downolad Resume</a></center>